# 05-ATM.py


money = 500
# 主菜单函数
def hello(name):
    print(f'{name},你好欢迎来到建设银行。请选择操作：')
    while True:
        print('查询余额','[输入1]')
        print('存款\t','[输入2]')
        print('取款\t','[输入3]')
        print('退出\t','[输入4]')
        index = int(input('请输入您的选择：'))
        if index==4:break; # 结束循环
        if index==1: sel_money(name)
        if index==2:add_money(name)
        if index==3:q_money(name)
# 查询余额
def sel_money(name):
    print("----------------查询余额----------------")
    print(f'{name},你好,您的余额剩余:{money}RMB')
# 存款
def add_money(name):
    a = int(input('请输入存款金额'))
    global money # 提升变量
    money = money + a
    print(f'{name}，你好，当前存款金额为{money}RMB')
    print(f'{name},你好，剩余金额{money}RMB')
# 取款
def q_money(name):
    a = int(input('请输入取款金额：'))
    global money
    if a>money:
        print('没钱还取啥')
    else:
        money-=a
        print(f'请确认取款金额为{money}RMB')
        print(f'当前余额剩余：{money}RMB')
# 主函数
def atm(name):
    hello(name)

atm('敦哥')